home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
fft_jm
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
12KB
From: John Paul Morrison <jmorriso@ee.ubc.ca>
Subject: v03i043: fft_jm - New FFT v1.0, Part01/01
Newsgroups: comp.sources.hp48
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu
Checksum: 3095338785 (verify with brik -cv)
Submitted-by: John Paul Morrison <jmorriso@ee.ubc.ca>
Posting-number: Volume 3, Issue 43
Archive-name: fft_jm/part01
BEGIN_DOC fft.doc
(main stuff: FFT, IFFT, the rest are just token utilities)
RPL FFT program
This is an FFT program written (mostly) in RPL. I've included
some support programs that will help analysis of signals etc.
The original algorithm and code (VFFT) was written by Nicola Catacchio
(e-mail: ares@alessia.unipd.it). Her code was the fastest user code
I have seen, so that's why I recoded it in RPL. This new FFT
code is 1.7 time faster for complex vectors, and 1.5 times faster
for real vectors, than the original VFFT program, and at least twice
as fast as others.
some sample times:
128 element (complex)
RPL FFT: 49 s
VFFT: 84 s
others: 100 s
64 element (complex)
RPL FFT: 20 s
VFFT: 35 s
others: 41 s
RPL code is often around 10 times faster than user code, but
unfortunately, the bottle-neck here is with the RPL complex multiply,
and less significantly with other complex operations. The HP routine
for a complex multiply is done in RPL, not machine code (ie they call
the rpl multiply, which is in machine code).
To get some more performance, I recoded the complex mulitplies, since
the built in complex multiply uses extended precision arithmetic.
Standard precision is faster, and the error is not significant (since
the FFT algorithm doesn't compund errors the way other algorithms do).
If anyone has looked at the FFT problem, I'd like to talk to them,
and try and improve performance. Send e-mail to John Paul Morrison,
jmorriso@ee.ubc.ca. I have not posted the RPL source-code, but I
can email it to those interested.
Rather than waiting any longer (until the routines are elegantly coded)
here are the programs, with brief descriptions:
FFT
This takes a real or complex vector. If the dimensions are not
2^N it will give an error message.
(run ASC\-> to decode after downloading)
IFFT
Inverts the FFT.
SAMPLE
'algebraic'
'name'
start
finish
n
This returns n samples in a vector. It samples the 'algebraic' with
independent variable 'name' from times start to finish.
PLOT
Useful for time domain plots.
Does a bar-plot of a vector V(1...N). V(1) is plotted on the left,
and V(N) is on the right.
PLOTF
Useful for frequency domain plots.
Does a bar-plot of a vector V(1...N). V(1) is in the center, plotted
up to V(N/2) on the right. V(N/2+1)..V(N). are on the left.
CLR
Clears the pict, and statistics information etc.
SINC
RECT
TRI
Defines some familiar communications signals.
LIN
LIN(t,t1,f1,t2,f2)
This defines a straight line from (t1,f1) to (t2,f2) within the range
t1...t2; with zero otherwise. This is useful for defining discontinuous
functions with lots of straight lines in it.
John Paul Morrison.
END_DOC
BEGIN_RDME fft.rdm
[ The rpl version of this program has the program fft asc'ed.
Fft has to be converted before it can be used. However, the
asc & uuencoded parts of this post already have fft
converted so you do not have to convert it yourself.
Chris ]
END_RDME
BYTES: #FF8Ch 2003
BEGIN_RPL fft.rpl
%%HP: T(3)A(R)F(.);
DIR
PLOT
\<< DUP OBJ\-> EVAL
\-> N
\<< { N 1 }
\->ARRY STO\GS BARPLOT
GRAPH
\>>
\>>
PLOTF
\<< DUP OBJ\-> EVAL
\-> N
\<< 1 N 2 /
START N
ROLL
NEXT { N 1
} \->ARRY STO\GS
BARPLOT GRAPH
\>>
\>>
ABSV
\<< OBJ\-> EVAL \-> N
\<< 1 N
START N
ROLL ABS
NEXT N
\->ARRY
\>>
\>>
SAMPLE
\<< 0 \-> f t t0 t1
n s
\<< { } t + 'f'
APPLY f = DEFINE t1
t0 - n 1 - / 's'
STO 1 n
FOR i t0 f
EVAL s 't0' STO+
NEXT n
\->ARRY
\>>
\>>
SINC
\<< \-> t
\<<
IF t 0 \=/
THEN t \pi *
DUP SIN SWAP /
ELSE 1
END
\>>
\>>
TRI
\<< \-> t
\<< t ABS
IF DUP 1 \<=
THEN 1 -
NEG
ELSE DROP 0
END
\>>
\>>
RECT
\<< \-> t
\<< t ABS .5 \<=
\>>
\>>
LIN
\<< \-> t t0 f0 t1
f1
\<<
IF t t0 < t
t1 > OR
THEN 0
ELSE f0 t
t1 - * f1 t t0 - *
- t0 t1 - /
END
\>>
\>>
FFT
"D9D20E16327792000000000000000100000000000000000EEDA1290D19C2A26C
7D178BF1F49B1ED2A2F49B150FA13CE223ABB14B2A2D9AE1AFE22D9D20900D1E
4A20510001050000000000000933A1B21305BF22D9D20AEC81881303004038D3
0CB916D9D2088130E8E3088130FC436FED30D00405923062E267F37088130122
70E0E3038D30CB916D9D2012270523302C230353161F03612270E9330B21306B
316322302A170B9826EE170D9D202C23021E26E8E3032230B21305E170CBD304
337079470B21309FF302C2309034647A2003D4303D4303D4303D4303D43B2130
0D470A69159FF3059230FBD81E6BA2ED2A2E6BA2EF9A2AEC8162E267F3707F42
583416D2E3088130C54160ED30FED300E5160F5162A1707E316006162A170E04
16C5416CC2162C230C2D5059230C2D50D7C26CB9A24C016EF116CB9A2E9016EF
116CB9A2CAF06CB9A2BBF06189A2CAF06479A272C50E041654D26CA130CFC15C
AF0661C15E0416E9330E0416C5416C2316E0416C5416F6E308F7268813000616
D00404EC3032230119200000838D3057B308C1702C230C2D5059230C2D50D7C2
6CB9A24C016EF116CB9A2E9016EF116CB9A2CAF06CB9A2BBF06189A2CAF06479
A272C507E316A18260F5166B3164EC308C17044230C5416F6E30526162BB1570
1252BB1543370442308341679470FBD81900D1B21305DF2293632B21304AA0"
IFFT
\<< CONJ FFT CONJ
DUP SIZE EVAL /
\>>
CLR
\<< { \GSPAR PPAR
\GSDAT PICT } PURGE
\>>
CST { PLOT PLOTF
ABSV SAMPLE SINC
TRI RECT LIN FFT
IFFT C\->R CLR }
END
END_RPL
BEGIN_ASC fft.asc
%%HP: T(3)A(D)F(.);
"69A20FF72FA0000000303435453047A2084E204005C4F44584E205005C4F4456
484E20401424356584E20603514D405C45484E20403594E43484E20304525948
4E20402554344584E2030C494E484E203064644584E204094646445E89C184E2
03034C425B2130CB0003034C42530D9D20E163247A2084E20405805142584E20
400505142584E204058441445634E1B2130EFE0293632B2130F5000409464644
540D9D20E1632E6AA184E2030646445E6AA178BF18B9C1EB3A150FA193632B21
30B40003064644530D9D20E16327792000000000000000100000000000000000
EEDA1290D19C2A26C7D178BF1F49B1ED2A2F49B150FA13CE223ABB14B2A2D9AE
1AFE22D9D20900D1E4A20510001050000000000000933A1B21305BF22D9D20AE
C81881303004038D30CB916D9D2088130E8E3088130FC436FED30D0040592306
2E267F3708813012270E0E3038D30CB916D9D2012270523302C230353161F036
12270E9330B21306B316322302A170B9826EE170D9D202C23021E26E8E303223
0B21305E170CBD304337079470B21309FF302C2309034647A2003D4303D4303D
4303D4303D43B21300D470A69159FF3059230FBD81E6BA2ED2A2E6BA2EF9A2AE
C8162E267F3707F42583416D2E3088130C54160ED30FED300E5160F5162A1707
E316006162A170E0416C5416CC2162C230C2D5059230C2D50D7C26CB9A24C016
EF116CB9A2E9016EF116CB9A2CAF06CB9A2BBF06189A2CAF06479A272C50E041
654D26CA130CFC15CAF0661C15E0416E9330E0416C5416C2316E0416C5416F6E
308F7268813000616D00404EC3032230119200000838D3057B308C1702C230C2
D5059230C2D50D7C26CB9A24C016EF116CB9A2E9016EF116CB9A2CAF06CB9A2B
BF06189A2CAF06479A272C507E316A18260F5166B3164EC308C17044230C5416
F6E30526162BB15701252BB1543370442308341679470FBD81900D1B21305DF2
293632B21304040030C494E430D9D20E16321C432D6E201047D6E20204703D6E
20206603D6E20204713D6E20206613E16323CE22D6E201047D6E20204703EBBE
1D6E201047D6E20204713D5CE1908E1AFE224B2A25BF22D9D20D6E20206603D6
E201047D6E2020471390DA1EEDA1D6E20206613D6E201047D6E2020470390DA1
EEDA190DA1D6E20204703D6E2020471390DA150FA1B21305DF22EF53293632B2
13033100402554344540D9D20E16321C432D6E201047E1632D6E201047F1AA13
39209990000000000050CFCE1EF53293632B2130060003045259430D9D20E163
21C432D6E201047E1632D6E201047F1AA13CE2278BF19C2A2CFCE1AFE22D9D20
9C2A290DA1599A1B21305BF22D9D208DBF14B2A2B21305DF22EF53293632B213
049000403594E43440D9D20E16321C432D6E201047E16323CE22D6E2010474B2
A2D9AE1AFE22D9D20D6E201047DBAA1EEDA178BF1CA4B1DBBF150FA1B21305BF
229C2A25DF22EF53293632B213059000603514D405C45460D9D20E16324B2A21
C432D6E201066D6E201047D6E20204703D6E20204713D6E2010E6D6E201037E1
63247A20B2130D6E20104776BA145632D6E20106697632D55F1D6E2010668D8A
156D02D6E20204713D6E2020470390DA1D6E2010E69C2A290DA150FA145632D6
E20103797632DCC029C2A2D6E2010E60A132D6E201096D6E20204703D6E20106
6EB3A1D6E20103745632D6E2020470397632B4402C4232D6E2010E6900D1EF53
293632B2130B6100401424356540D9D20E1632B7FC1EB3A11C432D6E2010E4E1
6329C2A2D6E2010E430132D6E2010E45BCF1F1AA1C4232D6E2010E4900D1EF53
293632B2130B70005005C4F4456450D9D20E163278BF1B7FC1EB3A11C432D6E2
010E4E16329C2A2D6E2010E4ED2A250FA130132D6E2010E45BCF1C423247A20D
6E2010E49C2A2B2130900D1B0DF133102AB2E1EF53293632B21305A0004005C4
F44540D9D20E163278BF1B7FC1EB3A11C432D6E2010E4E163247A20D6E2010E4
9C2A2B2130900D1B0DF133102AB2E1EF53293632B2130310F"
END_ASC
BYTES: #F013h 1470
BEGIN_UU fft.uue
begin 644 fft
M2%!(4#0X+466*O!_\@H````#0U-4`W0J@.0"!%!,3U1(+E``Q?1$983D`@1!$
M0E-62"Y@,!74!,54A.0"!%-)3D-(+C!`)96$Y`($4D5#5$@N,,"4Y(3D`@-&<
M1E1(+D"09&1$Y9@<2"XP,,0DM1(#O``P,,0D-=#9`AXV0J<"2"Y`4`@5)(7D=
M`@104$%22"Y`4$@41&5#'BLQX.\@.3:R$@-?`$"09&1$1=#9`AXVXJ8:2"XP0
M8&1$Y:8:A_N!FQR^HU'P&CDVLA(#2P`P8&1$-=#9`AXV<I<"``````````$`>
M`````````.ZM(0D=R:)B?!V'^_&4&]ZB\I0;!:\Q["*CNT$K*IWJH>\BG2V0B
M`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00$<K*IWJ)
MH>\BG2W0Y@(!=+VJX=X:A_O!2AN]^U'P&BLQ4/LBR:)2_2+^-9)C(RLQ4`D`E
M!E-!35!,10:=+>!A([2B$DPC;2X08-;F`@%T;2X@0`?3Y@("=#%M+A#@UN8"Z
M`7,>-D*G`BLQT.8"`71GJT%E(VTN$&"69R-=]='F`@%FV*A1UB!M+B!`%]/FZ
M`@)T,`FMT>8"`6[)HI+0&@6O064C;2X0,)=G(\T,DBPJ;2X0X`8:(VTN$)#6-
MY@("=#!M+A!@YCL:;2X0,$=E(VTN($`'DV<C2P3")"-M+A#@E@`=_C628R,K+
M,;`6``1!0E-6!)TMX&$C>\_A.QK!--+F`@%.'C:2+"IM+A#@-!`C;2X0X%3+C
M'Q^JP20C;2X0X)0`'?XUDF,C*S&P!P`%4$Q/5$8%G2W@82.'^['W'+ZC$4PC^
M;2X0X.1A(\FBTN8"`4[>HE+P&@,QTN8"`4ZU_,$D(W0JT.8"`4[)HK(2`PG0`
ML=`?,P&B*Q[^-9)C(RLQ4`H`!%!,3U0$G2W@82.'^['W'+ZC$4PC;2X0X.1AA
?(W0JT.8"`4[)HK(2`PG0L=`?,P&B*Q[^-9)C(RLQ`"LQ)
``
end
END_UU
--
__________________________________________________________________________
John Paul Morrison |
University of British Columbia, Canada |
Electrical Engineering | .sig closed for repairs
|
jmorriso@ee.ubc.ca |
________________________________________|_________________________________